package com.haixiaoke.saas.enterprise.order.controller;

import java.util.List;

import com.haixiaoke.saas.common.annotation.TenantScope;
import com.haixiaoke.saas.common.core.domain.AjaxResult;
import com.haixiaoke.saas.common.core.page.TableDataInfo;
import com.haixiaoke.saas.common.tenant.TenantContext;
import com.haixiaoke.saas.order.domain.CheckOutSubOrder;
import com.haixiaoke.saas.order.service.ICheckOutSubOrderService;
import com.haixiaoke.saas.system.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 退房订单子级订单退款Controller
 * 
 * @author panda
 * @date 2024-04-30
 */
@RestController
@RequestMapping("/enterprise/checkOutSubOrder")
public class EnterpriseCheckOutSubOrderController extends BaseController {
    @Autowired
    private ICheckOutSubOrderService checkOutSubOrderService;

    /**
     * 查询退房订单子级订单退款列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CheckOutSubOrder checkOutSubOrder) {
        startPage();
        List<CheckOutSubOrder> list = checkOutSubOrderService.selectCheckOutSubOrderList(checkOutSubOrder);
        return getDataTable(list);
    }

    /**
     * 退房订单子级订单退款--再次退款
     */
    @PostMapping("/refund")
    @TenantScope
    public AjaxResult refund(CheckOutSubOrder checkOutSubOrder) {
        checkOutSubOrder.setTenantId(TenantContext.getTenantId());
        return checkOutSubOrderService.refundCheckOutSubOrder(checkOutSubOrder);
    }
}
